home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d26 / inf_src.arc / MESSAGE1.C < prev    next >
C/C++ Source or Header  |  1986-03-14  |  3KB  |  112 lines

  1. #include <stdio.h>
  2.  
  3. #include "routine.h"
  4. #include "weather.h"    /* common definitions for direction and stuff */
  5.  
  6.  
  7. int main()
  8. /*
  9. **    note that argv[1] is a pointer to our array of common value
  10. */
  11.  
  12. {
  13. char    string[20] ;
  14. int    test ;
  15. int    value[20] ;
  16. FILE    *dataFile ;
  17.  
  18. dataFile = fopen("WEATHER.DAT","wb") ;
  19.  
  20. for(test = 0 ; test < 20 ; test++)
  21.     value[test] = 0 ;
  22.  
  23. /*
  24. **    value[0] = barometric pressure * 100
  25. **    value[1] = condition of pressure
  26. **        1-steady, 2-rise_slow, 3-rise_fast, 4-fall-slow, 5-fall-fast
  27. **    value[2] = direction of ground wind 
  28. **        1-n, 2-ne, 3-e, 4-se, 5-s, 6-sw, 7-w, 8-nw
  29. **
  30. */
  31.  
  32. printf("\n \nWEATHER EXPERT: \n") ;
  33. printf("\n This program attempts to prove one of the following:");
  34. printf("\n\tthe weather is ok\n\tthe weather is improving\n\tthe weather is deteriorating\n");
  35. printf("\nNot all weather cases are included in the forecast algorithm.");
  36. printf("\n\nBefore we attempt a forecast, I need some data\n What is the barometric pressure reading?\n");
  37. test = 0 ;
  38. while((test < 2000) || (test > 4000))
  39.     {
  40.     printf("\n(Type in the pressure as an integer (BP*100) 30.1 = 3010...?");
  41.     scanf("%d",&value[0]) ;
  42.     test = value[0] ;
  43.     }
  44. printf("\n\t Thankyou!,  \n\n Now I need to know how the barometer is acting\n");
  45. test = 0;
  46. while((test <1) || (test >5))
  47.     {
  48.     printf("\n\t Please input the correct number for the following:\n");
  49.     printf("\n\t 1 -- It is steady\n\t 2 -- It is rising slowly\n\t 3 -- It is rising rapidly") ;
  50.     printf("\n\t 4 -- It is falling slowly\n\t 5 -- It is falling rapidly \n?");
  51.     scanf("%d",&value[1]);
  52.     test = value[1] ;
  53.     }
  54. test = 0 ;
  55. printf("\n\t Thankyou,") ;
  56. while((test < 1) || ( test > 8 ) )
  57.     {
  58.     printf("\n\nNow I need the wind direction, which direction is it blowing from?\n");
  59.     printf("<n, ne, e, se, s, sw, w, nw>?") ;
  60.     scanf("%s",string) ;
  61.     if(0 == strcmp(string,"n"))
  62.         value[2]=NORTH ;
  63.     if(0 == strcmp(string,"ne"))
  64.         value[2]=NORTH_EAST ;
  65.     if(0 == strcmp(string,"e"))
  66.         value[2]=EAST ;
  67.     if(0 == strcmp(string,"se"))
  68.         value[2]=SOUTH_EAST ;
  69.     if(0 == strcmp(string,"s"))
  70.         value[2]=SOUTH ;
  71.     if(0 == strcmp(string,"sw"))
  72.         value[2]=SOUTH_WEST ;
  73.     if(0 == strcmp(string,"w"))
  74.         value[2]=WEST ;
  75.     if(0 == strcmp(string,"nw"))
  76.         value[2]=NORTH_WEST ;
  77.     if(0 == strcmp(string,"N"))
  78.         value[2]=NORTH ;
  79.     if(0 == strcmp(string,"NE"))
  80.         value[2]=NORTH_EAST ;
  81.     if(0 == strcmp(string,"E"))
  82.         value[2]=EAST ;
  83.     if(0 == strcmp(string,"SE"))
  84.         value[2]=SOUTH_EAST ;
  85.     if(0 == strcmp(string,"S"))
  86.         value[2]=SOUTH ;
  87.     if(0 == strcmp(string,"SW"))
  88.         value[2]=SOUTH_WEST ;
  89.     if(0 == strcmp(string,"W"))
  90.         value[2]=WEST ;
  91.     if(0 == strcmp(string,"NW"))
  92.         value[2]=NORTH_WEST ;
  93.     test = value[2] ;
  94.     }
  95. printf("\n\n\n\n For the next question, you should stand outside with your back");
  96. printf("\nto the surface wind.  You now must observe the direction the");
  97. printf("\nupper level clouds are moving.  You observe them to be moving") ;
  98. printf("\nfrom your right, from your left, or in a direction parallel") ;
  99. printf("\nto that which your are facing.\n") ;
  100. printf("\nUse this information to answer the following question.  If you");
  101. printf("\nare unable to see the upper level clouds, answer no to the following");
  102. printf("\nquestion.\n\n") ;
  103. fwrite(value,2,20,dataFile) ;
  104. fclose(dataFile) ;
  105. exit(RETURN_ROUTINE_TRUE) ;
  106. }
  107.  
  108.  
  109.  
  110.  
  111.  
  112.